# search the Maximum common factor
def mcf(x, y):
    (x, y) = (y, x) if x > y else (x, y)
    for num in range(x, 0, -1):
        if x % num == 0 and y % num == 0:
            return num


# search the Least common multiple
def lcm(x, y):
    factor = x * y // mcf(x, y)
    return factor


# Determine whether it is a palindrome
def is_palindrome(factor):
    num = 0
    temp = factor
    while temp > 0:
        num = num * 10 + (temp % 10)
        temp = temp // 10
    return factor == num


# Determine whether it is a prime
def is_prime(num):
    for i in range(2, int(num ** 0.5) + 1):
        if num % i == 0:
            return False
    return True if num != 1 else False

# Determine whether it is a prime and palindrome
if __name__=='__main__':
    num=int(input())
    if is_prime(num)and is_palindrome(num):
        print(True)
    else:
        print(False)